
package com.mp.controller;

import com.mp.ws.registro.RegistroWS_Service;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.WebServiceRef;


@WebServlet(name = "GravarHistoricoPreco", 
        urlPatterns = {"/GravarHistoricoPreco"})

public class GravarHistoricoPreco extends HttpServlet
{

    @WebServiceRef(wsdlLocation = "WEB-INF/wsdl/localhost_8080/" + 
            "MemoryPriceServerWS/RegistroWS.wsdl")
    private RegistroWS_Service service;

    
    @Override
    protected void doPost(HttpServletRequest request, 
    HttpServletResponse response)
            throws ServletException, IOException 
    {
    
        String idSessao = (String)request.getParameter("idSessaoRegistro");
        String idLocal = (String)request.getParameter("idLocal");
        String idItem = (String)request.getParameter("idItem");
        String valor = (String)request.getParameter("valor");
        String qtd = (String)request.getParameter("qtd");
        
        PrintWriter out = response.getWriter();
        
        try
        {
            setHistoricoPreco(idSessao, idLocal, idItem, valor, qtd);
            out.print("Preco inserido na base de dados.");
        }
        catch(Exception ex)
        {
            out.print("Erro ao incluir o preço na base de dados.");
        }
         
    }

    private void setHistoricoPreco(java.lang.String idSessaoUsuario, 
            java.lang.String idLocal, java.lang.String idItem, 
            java.lang.String valor, java.lang.String quantidade) 
    {
        com.mp.ws.registro.RegistroWS port = service.getRegistroWSPort();
        port.setHistoricoPreco(idSessaoUsuario, idLocal, 
                idItem, valor, quantidade);
    }
  

   

   
}
